<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="Order.Order" %>
<%@ page import="Page.Page"   %>
<%@ page import="java.util.*"  %>
<%@ page import="Order.SearchOrder"%>
<%
   //从数据库中去出结果集
   int currentRecord = 0;
   String DeleteID="";
   String UpdateID="";
   int flag=0;
   String sql="";
   int k=0;
   int k1=0;
   Page pager=new Page();
   SearchOrder db=new SearchOrder();
   //此处需要改
   String value=(String)request.getParameter("value");
   ArrayList<Order> result =db.select((String)session.getAttribute("user")); 
   pager.setTotalRecord(result.size());
   pager.setTotalPage(result.size(),pager.getPageSize());
   //计算并设置分页的参数
   if(request.getParameter("currentRecord")!=null)
   {   
       currentRecord = Integer.parseInt(request.getParameter("currentRecord"));
       pager.setCurrentRecord(currentRecord);
       pager.setCurrentPage(currentRecord,pager.getPageSize());
   }
   //从结果集中取出当前页面要显示的子集
   List<Order> subResult = null;
   if(currentRecord == 0)
   {
       if(currentRecord+pager.getPageSize()<=result.size())
       {
            subResult = result.subList(0,pager.getPageSize());
       	
       }
       else
       {
       	   	subResult = result.subList(0,result.size());
       }
   
   }
   else if(pager.getCurrentRecord()+pager.getPageSize()<result.size())
       subResult = result.subList(pager.getCurrentRecord(),pager.getCurrentRecord

()+pager.getPageSize());
   else
       subResult = result.subList(pager.getCurrentRecord(),result.size());
 %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>订单处理</title>
<link href="../css/shopbus.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div class="top_img">
</div>
<div class="busWord">
</div>
<div class="bus_order"> 
<table width="963" height="160" border="0">
  <tr>
    <td width="80" height="61"><img src="../images/order_5_11.png" /></td>
    <td width="62"><img src="../images/order_5_13.png" /></td>
    <td width="96"><img src="../images/order_5_15.png" /></td>
    <td width="96"><img src="../images/order_5_17.png" /></td>
    <td width="77"><img src="../images/order_5_19.png" width="57" height="14" /></td>
    <td width="80"><img src="../images/order_5_21.png" width="27" height="14" /></td>
     <td width="99">金额</td>
    <td width="72"><img src="../images/order_5_25.png" width="56" height="14" /></td>
    <td width="101"><img src="../images/order_5_27.png" width="42" height="14" /></td>
     <td width="99">是否处理</td>
    <td width="105">备注</td>
    <td width="49">是否成功处理</td>
  </tr>	<%
   			 if(subResult.isEmpty()==false)
		       {
		             for(int i=0;i<subResult.size();i++)
		             {
		                 Order order = subResult.get(i);
						 out.print("<tr>");
		                 out.print("<td>"+order.getOrderID()+"</td>");
		                 out.print("<td>"+order.getBuyerID()+"</td>");
		                 out.print("<td>"+order.getSellerID()+"</td>");
		                 out.print("<td>"+order.getComID()+"</td>");
		                 out.print("<td>"+order.getComName()+"</td>");
		                 out.print("<td>"+order.getOrderNum()+"</td>");
		                 out.print("<td>"+order.getOrderPrice()+"</td>");
		                 out.print("<td>"+order.getOrderTime()+"</td>");
		                 out.print("<td>"+order.getOrderToDate()+"</td>");
		                 out.print("<td>"+order.turn(order.getOrderIsChecked())+"</td>");
		                 out.print("<td>"+order.getOrderInf()+"</td>");
		                 if(order.getOrderIsChecked()==0)
		                 {
		                 	 out.print("<td>"+"<a href='UpdateOrder.jsp?UpdateID="+order.getOrderID()+"&flag=1'>是</a>");
			                 out.print("&nbsp&nbsp&nbsp&nbsp");
			                 out.print("<a href='UpdateOrder.jsp?UpdateID="+order.getOrderID()+"&flag=2'>否</a>"+"</td>");
			                 out.print("</tr>");   
		                 }
		                 else
		                 {
		                     out.print("<td>"+order.turn(order.getOrderIsChecked())+"</td>");
		                 	 out.print("</tr>"); 
		                 }
		                
		             }
		        }
   		 %>	
</table>

</div>
<div class="bus_bottom_page">
   	<span><font size="2">总<%=pager.getTotalRecord()%>条记录|总<%=pager.getTotalPage()%>页|当

前<%=pager.getCurrentPage()+1%>页|每页<%=pager.getPageSize()%>条|
<% 
    //如果已经到了首页就去掉前一页的链接
    if(pager.getCurrentRecord()-pager.getPageSize()<0)
        out.println("首页|");
    else
    //上一页就是把当前记录位置减去一页显示记录的条数
        out.print("<a href='OrderDeal.jsp?currentRecord="+(pager.getCurrentRecord()-

pager.getPageSize())+"&pageSize="+pager.getPageSize()+"'>上一页</a>|");
    //如果到了尾页就去掉下一页的链接
    if(pager.getCurrentRecord()+pager.getPageSize()>=pager.getTotalRecord())
        out.println("尾页");
    else
    //下一页就是把当前记录位置加上一页显示记录的条数
        out.print("<a href='OrderDeal.jsp?currentRecord="+(pager.getCurrentRecord

()+pager.getPageSize())+"&pageSize="+pager.getPageSize()+"'>下一页</a>|"); 
%>
</font></span></div>
	
</body>
</html>
